package com.cskaoyan.controller;

import com.cskaoyan.bean.Cart;
import com.cskaoyan.bean.basebean.BaseRespVo;
import com.cskaoyan.bean.cart.CartIndexVo;
import com.cskaoyan.service.CartService_;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 姚旭佳
 */
@RestController
@RequestMapping("wx/cart")
public class CartController_ {

    @Autowired
    CartService_ cartService;

    @RequestMapping("goodscount")
    public  BaseRespVo cartGoodscount(){
        long count=cartService.cartGoodscount();
        return BaseRespVo.ok(count);
    }
    @RequestMapping("add")
    public  BaseRespVo addCart(@RequestBody Cart cart){
        cartService.addCart(cart);
        long count=cartService.cartGoodscount();
        return BaseRespVo.ok(count);
    }
    @RequestMapping("index")
    public BaseRespVo cartIndex(){

        CartIndexVo vo=cartService.cartIndex();
        return BaseRespVo.ok(vo);
    }
    @RequestMapping("update")
    public BaseRespVo cartUpdate(@RequestBody Cart cart){

        cartService.cartUpdate(cart);
        return BaseRespVo.ok();
    }
}
